#include <hidef.h>
#include "derivative.h"
#include "atd.h"

void atd_init(void) {  
  ATD0CTL2 = 0x80;
  ATD0CTL4 = 0x05;
}

int atd_getValue(unsigned short chan){ 
  
  ATD0CTL5 = (unsigned char)chan;           // start sequence
  while((ATD0STAT1&0x01)==0){};             // wait for CCF0 
  return ATD0DR0H; 

}